package com.transcargo.util;

import java.util.StringTokenizer;
import java.util.Date;
import java.util.Calendar;

public class Checker {

	public static Boolean CheckDate(String date) {
		StringTokenizer tok = new StringTokenizer(date,".");
		if (tok.countTokens() < 3) return false;
		String day,month,year;
		day = tok.nextToken();
		month = tok.nextToken();
		year = tok.nextToken();
		try {
			if (day.length() == 0 || Integer.parseInt(day) == 0 || Integer.parseInt(day) > 31) return false;
			if (month.length() == 0 || Integer.parseInt(month) == 0 || Integer.parseInt(month) > 12) return false;
			if (year.length() == 0 || Integer.parseInt(year) < 2011) return false;
		} catch (NumberFormatException e) {
			return false;
		}
		return true;
	}
	public static Boolean CheckTime(String time) {
		StringTokenizer tok = new StringTokenizer(time,":");
		if (tok.countTokens() < 2) return false;
		String hour,min;
		hour = tok.nextToken();
		min = tok.nextToken();
		try {
			if (hour.length() == 0 || Integer.parseInt(hour) > 23) return false;
			if (min.length() == 0 || Integer.parseInt(min) > 59) return false;
		} catch (NumberFormatException e) {
			return false;
		}
		return true;
	}
}
